package com.fh.binarysearch;

/**
 * 153. 寻找旋转排序数组的最小值
 * @author fuhao
 * @date 2025/10/14 21:55
 */
public class T153FindMin {
    class Solution {
        public int findMin(int[] nums) {
            int left = 0;
            int right = nums.length - 1;

            while (left < right) {
                int mid = left + (right - left) / 2; // 防止溢出
                if (nums[mid] > nums[right]) {
                    // 最小值在mid右侧
                    left = mid + 1;
                } else {
                    // 最小值在mid左侧（包括mid）
                    right = mid;
                }
            }
            return nums[left];
        }
    }
}
